package com.shkco.controller;

import com.shkco.domain.MovieTicket;
import com.shkco.dto.MovieTicketDto;
import com.shkco.service.IMovieTicketService;
import com.shkco.result.JSONResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/movie")
public class MovieTicketController {

    @Autowired
    private IMovieTicketService movieTicketService;

    @GetMapping("/findAll")
    public JSONResult findAll(){
        return JSONResult.success(movieTicketService.findAll());
    }

    @GetMapping("/findById/{id}")
    public JSONResult findById(@PathVariable("id")Long id){
        return JSONResult.success(movieTicketService.findById(id));
    }

    @PostMapping("/buyMovie")
    public JSONResult buyMovie(@RequestBody MovieTicketDto movieTicketDto){
        return JSONResult.success(movieTicketService.buyMovie(movieTicketDto));
    }
}
